package com.ruoyi.service.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.service.domain.ServiceDetailsMerchant;
import com.ruoyi.service.service.IServiceDetailsMerchantService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务详情和商户中间Controller
 * 
 * @author wsc
 * @date 2025-05-12
 */
@RestController
@RequestMapping("/merchantanddetails")
public class ServiceDetailsMerchantController extends BaseController
{
    @Autowired
    private IServiceDetailsMerchantService serviceDetailsMerchantService;

    /**
     * 查询服务详情和商户中间列表
     */
    @RequiresPermissions("evaluate:merchantanddetails:list")
    @GetMapping("/list")
    public TableDataInfo list(ServiceDetailsMerchant serviceDetailsMerchant)
    {
        startPage();
        List<ServiceDetailsMerchant> list = serviceDetailsMerchantService.selectServiceDetailsMerchantList(serviceDetailsMerchant);
        return getDataTable(list);
    }

    /**
     * 导出服务详情和商户中间列表
     */
    @RequiresPermissions("evaluate:merchantanddetails:export")
    @Log(title = "服务详情和商户中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceDetailsMerchant serviceDetailsMerchant)
    {
        List<ServiceDetailsMerchant> list = serviceDetailsMerchantService.selectServiceDetailsMerchantList(serviceDetailsMerchant);
        ExcelUtil<ServiceDetailsMerchant> util = new ExcelUtil<ServiceDetailsMerchant>(ServiceDetailsMerchant.class);
        util.exportExcel(response, list, "服务详情和商户中间数据");
    }

    /**
     * 获取服务详情和商户中间详细信息
     */
    @RequiresPermissions("evaluate:merchantanddetails:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(serviceDetailsMerchantService.selectServiceDetailsMerchantById(id));
    }

    /**
     * 新增服务详情和商户中间
     */
    @RequiresPermissions("evaluate:merchantanddetails:add")
    @Log(title = "服务详情和商户中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceDetailsMerchant serviceDetailsMerchant)
    {
        return toAjax(serviceDetailsMerchantService.insertServiceDetailsMerchant(serviceDetailsMerchant));
    }

    /**
     * 修改服务详情和商户中间
     */
    @RequiresPermissions("evaluate:merchantanddetails:edit")
    @Log(title = "服务详情和商户中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceDetailsMerchant serviceDetailsMerchant)
    {
        return toAjax(serviceDetailsMerchantService.updateServiceDetailsMerchant(serviceDetailsMerchant));
    }

    /**
     * 删除服务详情和商户中间
     */
    @RequiresPermissions("evaluate:merchantanddetails:remove")
    @Log(title = "服务详情和商户中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceDetailsMerchantService.deleteServiceDetailsMerchantByIds(ids));
    }
}
